package cn.gxa.j229.bug.finance.controller.loanuser;

import cn.gxa.j229.bug.finance.pojo.PlatformFunds;
import cn.gxa.j229.bug.finance.pojo.RechargeRecord;
import cn.gxa.j229.bug.finance.service.loanuser.RechargeRecordService;
import cn.gxa.j229.bug.finance.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: fenglin
 * @Date:2020/9/26 19:06
 * @Version 1.0
 * 充值记录表
 */
@Controller
@RequestMapping("/rechargeRecord")
public class RechargeRecordController {

    @Autowired
    RechargeRecordService rechargeRecordService;


    JsonResult jsonResult=new JsonResult();

    @PostMapping("/selectAll")
    @ResponseBody
    public Map findAll(@RequestBody RechargeRecord rechargeRecord){

        Integer limit = rechargeRecord.getLimit();
        Integer page = rechargeRecord.getPage();

        List<Map<String, String>> select = rechargeRecordService.selectAll(rechargeRecord);

        int count = rechargeRecordService.selectAllCount(page, limit);

        jsonResult.put("count",count);
        jsonResult.setData(select);
        jsonResult.setCode("200");
        jsonResult.setMsg("成功");
        return jsonResult.getValues();
    }

    @PostMapping("/selectDateAndPhoneRenumber")
    @ResponseBody
    public Map selectDateAndPhoneRenumber(@RequestBody RechargeRecord rechargeRecord){

        Integer limit = rechargeRecord.getLimit();
        Integer page = rechargeRecord.getPage();
        Date startDate = rechargeRecord.getStartDate();
        Date endDate = rechargeRecord.getEndDate();
        String phone = rechargeRecord.getPhone();
        String renumber = rechargeRecord.getRenumber();
        Integer retpye = rechargeRecord.getRetpye();
        Integer state = rechargeRecord.getState();
            List<Map<String, String>> maps = rechargeRecordService.selectDateAndPhoneRenumber(rechargeRecord);
            int count = rechargeRecordService.selectDateAndPhoneRenumberCount(rechargeRecord);
            jsonResult.put("count",count);
            jsonResult.setData(maps);
            jsonResult.setCode("200");
            jsonResult.setMsg("成功");




        return jsonResult.getValues();
    }

}
